#pragma once

class CThumbnailWindow :
	public CWindowImpl<CThumbnailWindow>
{
	Image *_pThumbnail;

public:
	CThumbnailWindow()
		: _pThumbnail(NULL)
	{
	}

	~CThumbnailWindow()
	{
		delete _pThumbnail;
	}

	void SetThumbnail(Image *pThumbnail)
	{
		_pThumbnail = pThumbnail;
		Invalidate();
	}

	BEGIN_MSG_MAP(CThumbnailWindow)
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
		MESSAGE_HANDLER(WM_PAINT, OnPaint)
	END_MSG_MAP()

	LRESULT OnEraseBkgnd(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		return 0;
	}

	LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
	{
		PAINTSTRUCT ps;
		HDC hDC = BeginPaint(&ps);

		Graphics g(hDC);
		g.DrawImage(_pThumbnail, 0, 0);

		EndPaint(&ps);
		return 0;
	}
};
